package com.dscyy.readutil;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class TestCal {
	public static void main(String[] args) throws Exception {
		BigDecimal bg = new BigDecimal(12.2323243);
		double   f1   =   bg.setScale(4,   BigDecimal.ROUND_HALF_UP).doubleValue();  
		System.out.println(f1);
		
		String startDate = "2018-07-03 12:00:30";
		System.out.println(addTimeByMinute(startDate, -480));
	}
	
	public static String addTimeByMinute(String startDate, int minutes) throws ParseException {
		SimpleDateFormat f=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar c = Calendar.getInstance();
		c.setTime(f.parse(startDate));
		c.add(Calendar.MINUTE, minutes);
		return f.format(c.getTime());
	}
}
